/**   
* @Title: Project.java
* @Package cn.edu.sjtu.se.dslab.project
* @Description: TODO(用一句话描述该文件做什么)
* @author Thinker
* @date 2013-9-11 上午10:47:44
* @version V1.0
*/ 
package cn.edu.sjtu.se.dslab.project;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.edu.sjtu.se.dslab.auth.User;
import cn.edu.sjtu.se.dslab.component.aadl.AADLModel;
import cn.edu.sjtu.se.dslab.component.design.DesignPatternComponent;

/** 
 * @ClassName: Project
 * @Description: Use the project to organize
 * @author Thinker
 * @date 2013-9-11 上午10:47:44
 * 
 */
@Entity
@Table(name = "project")
public class Project implements Serializable{
	private static final long serialVersionUID = 3266329354535100561L;

	private long id;
	
	private String name;
	
	private User owner;

	private Date createTime;

	private String description;
	
	private String folderPath;

	private String uri;
	
	private List<DesignPatternComponent> designPatternComponents;
	
	private AADLModel model;
	
	private String rhapsodyFile;
	
	private PGroup pgroup;
	
	private boolean template = false;
	
	private boolean deleted;
	
	
	@Column(name = "deleted", nullable = true)
	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}


	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public long getId() {
		return id;
	}

	
	public void setId(long id) {
		this.id = id;
	}
	
	@Column(name = "name", nullable = true, length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH})
	@JoinColumn(name = "owner_id")
	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false, insertable = true, updatable = false, name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "description", nullable = true, length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(name="folder_path", nullable=false, length=255)
	public String getFolderPath() {
		return folderPath;
	}

	public void setFolderPath(String folderPath) {
		this.folderPath = folderPath;
	}


	@Column(name = "uri", nullable = true, length = 255)
	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}
	
	
	@Column(name = "rhapsody_file", nullable = true, length = 255)
	public String getRhapsodyFile() {
		return rhapsodyFile;
	}


	public void setRhapsodyFile(String rhapsodyFile) {
		this.rhapsodyFile = rhapsodyFile;
	}


	@OneToMany(cascade = CascadeType.REFRESH, mappedBy="project")
	public List<DesignPatternComponent> getDesignPatternComponents() {
		return designPatternComponents;
	}

	public void setDesignPatternComponents(
			List<DesignPatternComponent> designPatternComponents) {
		this.designPatternComponents = designPatternComponents;
	}
	
	@OneToOne(mappedBy="project",fetch=FetchType.EAGER,cascade = { CascadeType.REFRESH })   
	public AADLModel getModel() {
		return model;
	}


	public void setModel(AADLModel model) {
		this.model = model;
	}

	
	@ManyToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "pgroup_id", nullable = false)
	public PGroup getPgroup() {
		return pgroup;
	}

	public void setPgroup(PGroup pgroup) {
		this.pgroup = pgroup;
	}

	@Column(name = "template", nullable = true)
	public boolean isTemplate() {
		return template;
	}


	public void setTemplate(boolean template) {
		this.template = template;
	}
	
	
	
	
}
